#-----------------------------------------------------------------------------
# Project:     Midterm Exam Game
# Name:        Paddle.py
# Purpose:     Controllable Paddle Object
# 
# Authors:     Matthew Hahn
# Main Author: Matthew Hahn
#
# Created:     1/15/2013
# Copyright:   (c) Matthew Hahn 2012
# Licence:     New BSD
#-----------------------------------------------------------------------------
import pygame, math, sys, random
#stuff 
class Paddle():
    def __init__(self, maxSpeed, position):
        self.surface = pygame.image.load("rsc/paddle/paddle.png")
        self.surface = pygame.transform.scale(self.surface,
                                              (100, 30))
        self.rect = self.surface.get_rect()
        self.speed = [0,0]
        self.maxSpeed = maxSpeed
        self.place(position)
        self.radius = self.rect.width/2
        self.living = True
        
    def  __str__(self):
        return "I'm a paddle" + str(self.rect.center)
        
    def direction(self, dir):
        #print "I am trying to move", dir
        if dir == "Up":
            self.speed[1] = -self.maxSpeed
        elif dir == "Down":
            self.speed[1] = self.maxSpeed
        elif dir == "Stop Up":
            self.speed[1] = 0
        elif dir == "Stop Down":
            self.speed[1] = 0
            
        if dir == "Right":
            self.speed[0] = self.maxSpeed
        elif dir == "Left":
            self.speed[0] = -self.maxSpeed
        elif dir == "Stop Right":
            self.speed[0] = 0
        elif dir == "Stop Left":
            self.speed[0] = 0
        #taken from Man.py
     
    def place(self, position):
        print "I've moved to", position
        self.rect = self.rect.move(position)
        #Taken from ball.py in balldemo
        
    def move(self):
        print "I've moved", self.speed
        self.rect = self.rect.move(self.speed)
        #taken from robot.py in zombotapocolypse
            
    def collideWall(self, screenWidth, screenHeight):
        print "trying to hit edges of screen", screenWidth, screenHeight
        if (self.rect.left < 0 
            or self.rect.right > screenWidth):
            self.speed[0] = self.speed[0]*-1
        if (self.rect.top < 0 
            or self.rect.bottom > screenHeight):
            self.speed[1] = self.speed[1]*-0
            #taken from ball.py
        
        
        
        
        
        
        
        
        
        
        
        